<%@ Page Language="C#" %>
<%@ Register Namespace="WebControl.Alert" 
    TagPrefix="ms"
    Assembly="WebControlAlert" %>

<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    public void ServerShow(object sender, EventArgs e)
    {
        ServerAlert.Show();
    }

    public void ServerAlertChoice(object sender, AlertChoiceEventArgs e)
    {
        AlertResult.Text = "You clicked " + e.Result.ToString();
        AlertResult.Visible = true;
    }

    public void ConfirmClick(object sender, EventArgs e) {
        ConfirmResult.Visible = true;
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Alert WebControl</title>
    <style type="text/css">
        body {font-name:Arial}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        This page shows different uses of the Alert and ConfirmButton controls.<br />
         Don't use CssClass on an alert because it's a different window. Use inline styles instead. 
        <ms:Alert ID="ServerAlert" runat="server" buttons="OK" title="Server Alert" onchoice="ServerAlertChoice"
            font-names="Arial" horizontalalign="Center" width="350px" height="100px">
            This is a rich alert box that was triggered by<br /><i>server-side code</i>.<br />
        </ms:Alert>
        <ms:Alert ID="ClientAlert" runat="server" Buttons="YesNoCancel" Title="Client Alert" OnChoice="ServerAlertChoice"
            Font-Names="Arial" HorizontalAlign="Center" Width="350px" Height="140px">
            This is a rich alert box that was triggered by<br /><i>client-side code</i>.<br />
            The button will take the value that you chose.<br /><br />
        </ms:Alert>
        <asp:Button ID="ServerShowButton" runat="server" Text="Postback and show alert" OnClick="ServerShow" /><br />
        <input type="button" name="ClientShowButton" value="Show alert without posting back"
            onclick="this.value=<%= ClientAlert.GetShowClientEvent() %>;" /><br />
        <ms:ConfirmButton ID="Confirm" runat="server" OnClick="ConfirmClick"
            Text="Confirm Button" ConfirmText="Are you sure you want to press this button?" /><br />
        <ms:ConfirmButton ID="ConfirmClone" runat="server" OnClick="ConfirmClick"
            Text="Confirm Button with the same confirm text" ConfirmText="Are you sure you want to press this button?" /><br />
        <ms:ConfirmButton ID="Confirm2" runat="server" OnClick="ConfirmClick"
            Text="Confirm Button" ConfirmText="Are you really, really sure you want to press this button?" /><br />
        <asp:Label ID="AlertResult" runat="server" ForeColor="Red" Visible="false" />
        <asp:Label ID="ConfirmResult" runat="server" ForeColor="Red" Visible="false">Please don't press this button again.</asp:Label><br />
        <asp:GridView
            AutoGenerateColumns="False" DataSourceID="Datasource1" ID="GridView1" runat="server" DataKeyNames="ID">
            <SelectedRowStyle BackColor="gray" />
            <Columns>
                <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                    SortExpression="ID" Visible="False"></asp:BoundField>
                <asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name"></asp:BoundField>
                <asp:BoundField DataField="Alias" HeaderText="Alias" SortExpression="Alias"></asp:BoundField>
                <asp:TemplateField HeaderText="Command">
                    <ItemTemplate>
                        <ms:ConfirmButton ID="Confirm" runat="server"
                            Alert="GridSelectConfirmAlert" CommandName="select"
                            Text="Select" /><br />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:XmlDataSource runat="server" ID="Datasource1" XPath="/Customers/Customer">
            <Data>
                <Customers>
                    <Customer ID="1" Name="NorthWind" Alias="nwnd" />
                    <Customer ID="2" Name="Fabrikam" Alias="fbkm" />
                </Customers>
            </Data>
        </asp:XmlDataSource>
        <ms:Alert ID="GridSelectConfirmAlert" runat="server" Buttons="YesNo" Title="Are you sure?"
            Font-Names="Arial" HorizontalAlign="Center" Width="320px" Height="50px">
            Are you sure you want to select this row?
        </ms:Alert>
    </div>
    </form>
</body>
</html>
